//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing
{
    public class GroupLocking : IOfficeXmlSerializable
    {
        private bool noChangeAspect;
        private bool noGrp = false; //\\optional
        private bool noMove;
        private bool noResize;
        private bool noRot;
        private bool noSelect = false;
        private bool noUnGrp = false; //\\optional

        public bool NoUnGrp
        {
            get { return noUnGrp; }
            set { noUnGrp = value; }
        }

        public bool NoGrp
        {
            get { return noGrp; }
            set { noGrp = value; }
        }

        public bool NoSelect
        {
            get { return noSelect; }
            set { noSelect = value; }
        }

        public bool NoRot
        {
            get { return noRot; }
            set { noRot = value; }
        }

        public bool NoChangeAspect
        {
            get { return noChangeAspect; }
            set { noChangeAspect = value; }
        }

        public bool NoMove
        {
            get { return noMove; }
            set { noMove = value; }
        }

        public bool NoResize
        {
            get { return noResize; }
            set { noResize = value; }
        }

        #region IOfficeXmlSerializable Members

        void IOfficeXmlSerializable.ReadXml(ReadContext context)
        {
            using (var c = context.Read("grpSpLocks"))
            {
                NoChangeAspect = c.GetOptionalBoolean("noChangeAspect", false);
                NoGrp = c.GetOptionalBoolean("noGrp", false);
                NoUnGrp = c.GetOptionalBoolean("noUngrp", false);
                NoMove = c.GetOptionalBoolean("noMove", false);
                NoResize = c.GetOptionalBoolean("noResize", false);
                NoRot = c.GetOptionalBoolean("noRot", false);
                NoSelect = c.GetOptionalBoolean("noSelect", false);
                c.WarnIf("ext");
            }
        }

        void IOfficeXmlSerializable.WriteXml(WriteContext context)
        {
            using (WriteContext c = context.Write("grpSpLocks"))
            {
                c.SetOptionalBoolean("noChangeAspect", NoChangeAspect, false);
                c.SetOptionalBoolean("noGrp", NoGrp, false);
                c.SetOptionalBoolean("noUngrp", NoUnGrp, false);
                c.SetOptionalBoolean("noMove", NoMove, false);
                c.SetOptionalBoolean("noResize", NoResize, false);
                c.SetOptionalBoolean("noRot", NoRot, false);
                c.SetOptionalBoolean("noSelect", NoSelect, false);
                c.WarnIf("ext");
            }
        }

        #endregion
    }
}